/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.teknei.controller;

import com.teknei.util.Constants;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

/**
 *
 * @author JAMARO
 */
@Controller(Constants.CONTROLLER_LOGIN)
@Scope(Constants.SCOPE_SESSION)
public class LoginController extends BaseController implements Serializable{
    
    private String userName;
    private String fullUserName;
    
    private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);
    
    private void initUserName(){
        if(userName == null || userName.length() == 0){
             Authentication auth = SecurityContextHolder.getContext().getAuthentication();
             userName = auth.getName(); //get logged in username
        }
    }
    
    private void initFullUserName(){
        initUserName(); 
        fullUserName = userName;
    }
    /**
     * @return the userName
     */
    public String getUserName() {
        initUserName();
        return userName;
    }

    /**
     * @param userName the userName to set
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }

    /**
     * @return the fullUserName
     */
    public String getFullUserName() {
        initFullUserName();
        return fullUserName;
    }

    /**
     * @param fullUserName the fullUserName to set
     */
    public void setFullUserName(String fullUserName) {
        this.fullUserName = fullUserName;
    }
    
    
    
}
